package com.longrise.android.byjk.plugins.aboutme.personalInfo.person_honor;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.byjk.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/7.
 * 个人荣誉的adapter
 */

public class PersonHonorAdapter extends BaseQuickAdapter<PersonHonorBean, BaseViewHolder> {

    private List<EntityBean> mListBeans = new ArrayList<>();
    private OnItemClickListener mListener;
    private boolean isEdit;
    private ArrayList<PersonHonorBean> mSelectedHonorBeans = new ArrayList<>();

    public PersonHonorAdapter() {
        super(R.layout.item_rcv_person_honor);
    }

    public void setDatas(List<PersonHonorBean> childBeanList) {
        setNewData(childBeanList);
    }

    public void editData(boolean b) {
        this.isEdit = b;
        notifyDataSetChanged();
    }

    /**
     * 告诉item 选择了那几个
     */
    public void setSelectedCourseBeans(List<PersonHonorBean> selectedHonorBeans){
        mSelectedHonorBeans.clear();
        mSelectedHonorBeans.addAll(selectedHonorBeans);
        notifyDataSetChanged();
    }


    @Override
    protected void convert(BaseViewHolder helper, final PersonHonorBean honorBean) {
        View convertView = helper.getConvertView();
        RelativeLayout mRlgrry = (RelativeLayout) convertView.findViewById(R.id.item_person_honor_rl);
        TextView mTvgrry = (TextView) convertView.findViewById(R.id.item_person_honor_tv);
        mTvgrry.setText(honorBean.getHonordesc());

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mListener.onItemClick(honorBean);
            }
        });
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        this.mListener = listener;
    }

    public interface OnItemClickListener {

        void onItemClick(PersonHonorBean honorBean);
    }
}
